package com.laibatour.generator.entity;

import com.laibatour.generator.utils.GeneratorUtil;

public class Field {
	private String colName;
	private String colType;
	private int colSize;
	private boolean notNull;
	private String defaultValue;
	private String colComment;

	public String getColName() {
		return colName;
	}

    public String getName() {
        return GeneratorUtil.replace(colName);
    }

	public void setColName(String colName) {
		this.colName = colName;
	}

	public String getColType() {
        if("INT".equalsIgnoreCase(colType)) {
            return "INTEGER";
        }
		if("TEXT".equalsIgnoreCase(colType)) {
			return "VARCHAR";
		}
		return colType;
	}

	public void setColType(String colType) {
        this.colType = colType;
	}

	public int getColSize() {
		return colSize;
	}

	public void setColSize(int colSize) {
		this.colSize = colSize;
	}

	public String getJavaType() {
		if (colType.equals("BIT")) {
			return "Boolean";
		} else if (colType.equals("TINYINT")) {
			return "Integer";
		} else if (colType.equals("SMALLINT")) {
			return "Integer";
		} else if (colType.equals("INT") || colType.equals("BIGINT")) {
			return "Long";
		} else if (colType.equals("FLOAT") || colType.equals("REAL")) {
			return "Float";
		} else if (colType.equals("DECIMAL") ||colType.equals("NUMERIC")) {
			return "BigDecimal";
		} else if (colType.equals("VARCHAR") || colType.equals("CHAR")
				|| colType.equals("NVARCHAR") || colType.equals("NCHAR")
				|| colType.equals("TEXT")) {
			return "String";
		} else if (colType.equals("DATETIME") || colType.equals("DATE")) {
			return "Date";
		} else if (colType.equals("TIME")) {
			return "Time";
		} else if (colType.equals("TIMESTAMP")) {
			return "Timestamp";
		} else if (colType.equals("IMAGE")) {
			return "Blod";
		}
		return colType;
	}

    public boolean isNotNull() {
        return notNull;
    }

    public void setNotNull(boolean notNull) {
        this.notNull = notNull;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    public String getColComment() {
        return colComment;
    }

    public void setColComment(String colComment) {
        this.colComment = colComment;
    }
}
